<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="js/tools/jquery-1.4.2.min.js"></script>
<script charset="utf-8" src="js/editor/kindeditor.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    KE.show({
				id : 'describe',
				resizeMode : 1,
				allowPreviewEmoticons : false,
				allowUpload : false,
				items : [
				]
			});
      var targs = new Array(${userDetial.tags});
      
       var allTargs="";
     
     for(var i=0;i<targs.length;i++)
      {
         allTargs+="<a href='javascript:void(0);' onclick='delTags(this,\""+targs[i]+"\")'>"+targs[i]+"</a>";
      }
      $("#allTargs").html(allTargs);
     
});
function addTags()
{
  var tag=$("#tag").val();
  var tid=$("#tid").val();
  if($("#allTargs").text().indexOf(tag)!=-1)
  {
     alert("该关键词已经存在!");
     return false;
  }
  if(tag!="")
  {
      $("#allTargs").append("<a href='javascript:void(0);' onclick='delTags(this,\""+tag+"\")'>"+tag+"</a>");
      if(tid=="")
		 {
			 $("#tid").val("\""+tag+"\"");
		 }else
		 {
			 tag=",\""+tag+"\"";
			  $("#tid").val(tid+tag);
		 }
      
  }
}
function delTags(obj,tags)
{
$(obj).remove();
var tid=$("#tid").val();
 if(tid!=""&&tid.indexOf("\""+tags+"\"")==0)
		 {
			 $("#tid").val(tid.replace("\""+tags+"\"","").replace(",",""));
			 
		 }else
		 {
			 tags=",\""+tags+"\"";
			 tid=tid.replace(tags,"");
			  $("#tid").val(tid);
		 }
}
function startSubmit()
{
    var describe=$("textarea[name='describe']").val();
     var username=$("input[name='username']").val();
    var eusername=$("input[name='eusername']").val();
    var tid=$("#tid").val();
    if(username.length>10)
    {
     alert("中文名称不能大于10");
       return false;
    }
    if(eusername.length>40)
    {
     alert("英文名称不能大于40");
       return false;
    }
    if(describe.length>3000)
    {
       alert("个人描述字数不能大于3000");
       return false;
    }
    if(tid.length>200)
    {
       alert("个人关键词字数不能大于200");
       return false;
    }
    return true;
}
</script>
<style>
table{table-layout:fixed;font-size:12px;}
  tr{background-color:#F1F6F6;}
  td{border:1px solid #D9D9D9;color:black;padding:2px;}
  #allTargs a{text-decoration:none;table-layout:fixed;font-size:14px;margin-right:8px;}
  #keyword a{text-decoration:none;table-layout:fixed;font-size:14px;margin-right:8px;}
</style>
</head>
<body>
 <form action="groupby/admin/user!updateSingleUser.action" method="post" enctype="multipart/form-data"  onsubmit="return startSubmit();">
 <input type="hidden" id="tid" name="tags" value='<s:property value="userDetial.tags" escape="false"/>'>
 <table  style="width:80%;" align="center">
 <tr>
    <td width="80">名称:</td>
    <td><INPUT  name="username" value="<s:property value="userDetial.username"/>"/>
    </td>
 </tr>
 <s:if test="#session.user.level==4">
 <tr>
    <td width="80">英文名称:</td>
    <td><INPUT  name="eusername" value="<s:property value="userDetial.eusername"/>"/>
    </td>
 </tr>
 </s:if>
 
 <tr><td width="80">用户图片：</td>
     <td>
      <s:if test="userDetial.image.equals('')">
         <img src="uploadFile/img.gif" width="266" height="182"/>
      </s:if>
      <s:else>
          <img src="uploadFile/<s:property value="userDetial.image"/>" width="266" height="182"/>
      </s:else>
      <br/>
      <input type="file" name="file">
    </td>
 </tr>
 <tr><td width="80">
 <s:if test="#session.user.level==4">
 品牌介绍：
 </s:if>
 <s:else>
  个人介绍：
 </s:else>
 </td><td><textarea id="describe" name="describe" style="width:500px;height:150px;"><s:property value="userDetial.describale"/></textarea></td></tr>
 <tr>  
		       <td width="20%">添加关键词</td> 
		       <td ><input type="text" id="tag"/><a href="javascript:void(0);" onclick="addTags()">添加</a></td>
		     </tr> 
		     <tr>  
		       <td >已有关键词</td> 
		       <td ><div id="allTargs" style="float:left;width:600px;height:200px;border:1px solid #D9D9D9;color:black;padding:2px;overflow: auto;"></td>
		     </tr>
<tr>
    <td colspan="2" align="center">
       <input type="submit" value="保存">
    </td>
</tr>
</table>
</form>
</body>
</html>